/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Status.java
 *
 * Created on Jun 12, 2011, 3:02:14 AM
 */
package eu.anorien.dmo.gui.optimization;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class Status extends javax.swing.JPanel {

    /** Creates new form Status */
    public Status() {
        initComponents();
    }

    public synchronized void setAverageTimeToRun(long millis) {
        averageTimeToRunLabel.setText("" + (millis / 1000));
    }

    public synchronized void setAverageRunsPerMinute(long n) {
        averageRunsPerMinuteLabel.setText("" + n);
    }

    public synchronized void setBestPerformance(double error) {
        bestPerformanceLabel.setText("" + ((int) ((1 / error) * 1000)) / 1000d);
    }

    public synchronized void setRunningTime(long millis) {
        runningTimeLabel.setText("" + ((int) ((millis / (double) (1000 * 60)) * 100)) / 100d);
    }

    public synchronized void setBestParams(String params) {
        if (!bestParamsTextField.getText().equals(params)) {
            bestParamsTextField.setText(params);
        }
    }

    public synchronized void setCacheHits(int n) {
        cacheHitsLabel.setText("" + n);
    }

    public synchronized void setNumRuns(int n) {
        nRunsLabel.setText("" + n);
    }

    public synchronized void setPercentParamSpcaeExploredLabel(double p) {
        percentParamSpcaeExploredLabel.setText("" + ((int) ((p) * 1000)) / 1000d);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        runningTimeLabel = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        averageTimeToRunLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        bestPerformanceLabel = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        bestParamsTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        cacheHitsLabel = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        nRunsLabel = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        percentParamSpcaeExploredLabel = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        averageRunsPerMinuteLabel = new javax.swing.JLabel();

        jLabel1.setText("Running time (min):");

        runningTimeLabel.setText("0");

        jLabel3.setText("Average time to run function (sec):");

        averageTimeToRunLabel.setText("0");

        jLabel2.setText("Best performance:");

        bestPerformanceLabel.setText("0");

        jLabel6.setText("Best performance parameters:");

        bestParamsTextField.setEditable(false);

        jLabel4.setText("Cache hits:");

        cacheHitsLabel.setText("0");

        jLabel5.setText("Number function runs:");

        nRunsLabel.setText("0");

        jLabel7.setText("% of parameter space explored:");

        percentParamSpcaeExploredLabel.setText("0");

        jLabel8.setText("Average function runs per minute:");

        averageRunsPerMinuteLabel.setText("0");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(nRunsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(percentParamSpcaeExploredLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cacheHitsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(runningTimeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(averageTimeToRunLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(averageRunsPerMinuteLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bestPerformanceLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(bestParamsTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(nRunsLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(percentParamSpcaeExploredLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cacheHitsLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(runningTimeLabel)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(averageTimeToRunLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(averageRunsPerMinuteLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(bestPerformanceLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(bestParamsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel averageRunsPerMinuteLabel;
    private javax.swing.JLabel averageTimeToRunLabel;
    private javax.swing.JTextField bestParamsTextField;
    private javax.swing.JLabel bestPerformanceLabel;
    private javax.swing.JLabel cacheHitsLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel nRunsLabel;
    private javax.swing.JLabel percentParamSpcaeExploredLabel;
    private javax.swing.JLabel runningTimeLabel;
    // End of variables declaration//GEN-END:variables
}
